import parse from '@dfeidao/atom-web/dt/parse';
import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import fire from '@dfeidao/atom-web/msg/fire';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from '@dfeidao/atom-web/render/render';
import p001 from '../zj-000002/p001';
import p002 from '../zj-000002/p002';
export default async function a001(fd: IFeidaoAiBrowserComponent) {
	const training_name = fd.data.node.querySelector<HTMLInputElement>('[name="input1"]').value;
	const lecturer_name = fd.data.node.querySelector<HTMLInputElement>('[name="input2"]').value;
	let train_start_time = parse(fd.data.node.querySelector<HTMLInputElement>('[name="input3"]').value);
	let training_time = parse(fd.data.node.querySelector<HTMLInputElement>('[name="input4"]').value);
	console.log(train_start_time);
	if (!train_start_time) {
		train_start_time = 1203379200000;
	}
	if (!training_time) {
		training_time = new Date().getTime();
	}
	console.log(train_start_time + '---------' + training_time);
	const res = await nodejs<{ res: Array<{}>, ress: number }>('train-plan/zj-000001/s001', {
		filter: {
			training_name,
			lecturer_name,
			train_start_time,
			training_time
		}

	});
	console.log(res.res);
	console.log(res.ress);
	// render(fd, res.res, p001, 'p001', 'inner');
	// render(fd, res.ress, p002, 'p002', 'inner');

	fire('zj-000002', 'a001', JSON.stringify(res));

}
